package milktea.servlet.cart;

import milktea.dto.PRODUCT_DTO;
import milktea.entity.DETAIL;
import milktea.service.DETAILService;
import milktea.service.PRODUCTService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/order_detail")
public class OrderDetail extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");

        int oid = Integer.parseInt(req.getParameter("oid"));
        ArrayList<DETAIL> details= DETAILService.DetailByID(oid);
        System.out.println("DetailSize"+details.size());
        List<PRODUCT_DTO> pdlist= PRODUCTService.Detail_DtoByID(details);
        System.out.println(pdlist.size()+"--"+pdlist.get(0).getPRODUCT_NAME());
        req.setAttribute("detail_dto_list", pdlist);

//        req.getRequestDispatcher("goods.jsp").forward(req, resp);
        req.getRequestDispatcher("orderDetailPrev.jsp").forward(req, resp);

    }
}
